package com.yidian.demotickets;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.yidian.demotickets.SAXPrint.SAXPrint;
import com.yidian.demotickets.entity.SvgEntity;
import com.yidian.demotickets.utils.AidlUtil;
import java.io.IOException;
import java.io.InputStream;

public class MainActivity extends AppCompatActivity {
//retyrtytrtyttttttt
    private TextView textView;
    private Button btn,btn2;
    private SvgEntity svgEntity;
    private String fileName;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.xianshi);
        //初始化打印机
        AidlUtil.getInstance().initPrinter();

        btn= (Button) findViewById(R.id.btn);
        btn2= (Button) findViewById(R.id.btn2);
        textView= (TextView) findViewById(R.id.tv);

        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                fileName="jiezhangguke.svg";
                InputStream inputStream = null;
                try {
                    inputStream = getAssets().open(fileName);
                    SAXPrint saxPrint=new SAXPrint(MainActivity.this,inputStream);
                    saxPrint.print();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });
        btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                fileName="chongzhishangjia.svg";
                InputStream inputStream = null;
                try {
                    inputStream = getAssets().open(fileName);
                    SAXPrint saxPrint=new SAXPrint(MainActivity.this,inputStream);
                    saxPrint.print();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });


    }


}
